//
//  XMStatusCell.m
//  XMWeibo
//
//  Created by chi on 14-8-25.
//  Copyright (c) 2014年 xiaoming. All rights reserved.
//

#import "XMStatusCell.h"
#import "XMCellToolsBar.h"

#import "UIImageView+WebCache.h"
#import "XMOriginalStatusView.h"

#import "XMStatus.h"

@interface XMStatusCell ()

#pragma mark - topView
/** 用来放置原创微博内容视图 */
@property (nonatomic, weak) XMOriginalStatusView *topView;



#pragma mark - toolsBarView
/** 用来放置微博功能视图 */
@property (nonatomic, weak) XMCellToolsBar *toolsBarView;







@end

@implementation XMStatusCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //创建微博子控件
        [self setupStatusView];

        
        //创建微博工具栏
        [self setupToolsBarSubViews];
        
        
        //设置属性
        self.backgroundColor = [UIColor clearColor];
        self.selectedBackgroundView = [[UIView alloc]init];
    }
    return self;
}

/**
 *  创建原创微博子控件
 */
- (void)setupStatusView
{
    //topview容器
    XMOriginalStatusView *topView = [[XMOriginalStatusView alloc]init];
    
    self.topView = topView;
    [self.contentView addSubview:topView];
    
}



/**
 *  创建微博工具栏
 */
- (void)setupToolsBarSubViews
{
    XMCellToolsBar *toolsBarView = [[XMCellToolsBar alloc]init];

    
    self.toolsBarView = toolsBarView;
    
    [self.contentView addSubview:toolsBarView];
    
}


- (void)setStatusFrame:(XMStatusFrame *)statusFrame
{
    _statusFrame = statusFrame;
    
    self.topView.frame = statusFrame.topViewF;
    
    self.topView.statusF = statusFrame;
    
   
    //cell工具条
    self.toolsBarView.frame = statusFrame.toolsBarViewF;
    self.toolsBarView.status = statusFrame.status;
}

- (void)setFrame:(CGRect)frame
{
    frame.origin.y += kStatusCellEdge * 2;
    frame.size.height -= kStatusCellEdge * 2;
    
    
    [super setFrame:frame];
}

+ (XMStatusCell *)cellWithStatusFrame:(XMStatusFrame *)statusFrame andTableView:(UITableView *)tableView
{
    static NSString *reuseIdentifier = @"statusCell";
    
    
    XMStatusCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    
    
    if (cell == nil) {
        cell = [[XMStatusCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
    }
    
    [cell setStatusFrame:statusFrame];
    
    
    return cell;
}

@end
